#ifndef YOOHOO_XMPPCORE_STANZA_H
#define YOOHOO_XMPPCORE_STANZA_H

#include "xmppcore/export.h"
#include "xmppcore/jabberid.h"
#include "xmppcore/xmppelement.h"
#include "xmppcore/xmppobject.h"

#include <QtCore/QSharedDataPointer>
#include <QtCore/QObject>

namespace yoohoo_xmppcore {

class XmlWriter;

class StanzaSharedData : public QSharedData {
public:
	StanzaSharedData();
	StanzaSharedData(const StanzaSharedData& other);
	~StanzaSharedData();

	JabberId* from;
	JabberId* to;
	XmppObject* obj;
	QString id;
	QString type;
	QString xmlLang;
};

class YOOHOO_XMPPCORE_EXPORT Stanza : virtual public XmppElement {
	friend class StanzaParser;
public:
	enum StanzaKind {
		StanzaKindMessage,
		StanzaKindPresence,
		StanzaKindIq,
		StanzaKindUnknown
	};

	Stanza();
	Stanza(const Stanza& other);
	
	virtual void setFrom(const JabberId* from);
	virtual const JabberId* from() const;
	virtual void setTo(const JabberId* to);
	virtual const JabberId* to() const;
	virtual void setId(QString id);
	virtual QString id() const;
	virtual void setXmlLang(QString xmlLang);
	virtual QString xmlLang() const;
	virtual void setObj(XmppObject* obj);
	virtual XmppObject* obj();

	virtual QString toXml();
	virtual Stanza::StanzaKind stanzaKind() const = 0;
	virtual QString type() const;
	XmppElement::ElementType elementType() const;

protected:
	virtual void doToXml(XmlWriter* xmlWriter);

protected:
	QSharedDataPointer<StanzaSharedData> _d;
};

}

#endif
